package com.adnaan.restaurant.controller;

import com.adnaan.restaurant.common.untils.R;
import com.adnaan.restaurant.entity.ResDishes;
import com.adnaan.restaurant.service.IResDishesService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * author: adnaan
 * create: 2023-11-08 18:52
 * Description:
 */
@Tag(name = "菜品接口", description = "菜品相关功能")
@RestController
@RequestMapping("/restaurant/dishes")
public class ResDishesController {

    @Autowired
    private IResDishesService resDishesService;

    @Operation(summary = "菜品列表")
    @GetMapping("/list")
    public R list(@RequestParam Long shopId) {
        List<ResDishes> list = resDishesService.selectResDishesList(shopId);
        return R.success(list);
    }

    @Operation(summary = "模糊查询")
    @GetMapping("/searchByName")
    public R searchByName(@RequestParam String name) {
        List<ResDishes> list = resDishesService.selectResDishesByName(name);
        return R.success(list);
    }

    @Operation(summary = "菜品详情")
    @GetMapping("/detail")
    public R detail(@RequestParam Long id) {
        return R.success(resDishesService.selectResDishesById(id));
    }
}
